<?php

/**
 * ArticleCategorys form.
 *
 * @package    cms
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class ArticleCategorysForm extends BaseArticleCategorysForm
{
  public function configure()
  {
    $this->removeFields();

    $categorys = Doctrine::getTable('ArticleCategorys')->getTopArticleCategorys();
    
    $this->widgetSchema['parent_id'] = new sfWidgetFormChoice(
                array(
                   'choices' =>$categorys ,
                   'expanded'=>false,
                   'multiple'=>false
                )
            );
    
    $this->validatorSchema['parent_id'] = new sfValidatorChoice(
                array(
                   'choices' => array_keys($categorys),
                )
            );
    
    $this->validatorSchema['name'] = new sfValidatorString(
                array(
                    'required'=> true,
                    'max_length'=>100,
                    'min_length'=>3,
                    'trim'=>true,
                ),
                array(
                    'required'=>'名称不写会出错哦',
                    'max_length'=>'分类名太长不方便阅读',
                    'min_length'=>'分类名太短看不到哦',
                )
            );

    $this->validatorSchema['sort_num'] = new sfValidatorNumber(
                array(
                    'max' => 99999999,
                    'min' => -1,
                ),
                array(
                    'max'=>'哇塞，您的排序太大了',
                    'min'=>'排序不能小于0',
                    'invalid'=>'序号一定要是个数字哦',
                )
            );
    
    $this->widgetSchema->setLabels(
                array(
                    'parent_id'=>'上级分类',
                    'name'=>'分类名称',
                    'sort_num'=>'分类排序',
                )
              );
  }

  protected function removeFields()
  {
      unset(
              $this['created_at'],$this['updated_at']
              );
  }
}
